<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-model案例和原理</title>
</head>
<body>

<!-- 案例 -->
<div id="app">
  <input type="text" v-model="msg">{{msg}}
</div>

<!-- 原理 -->
<div id="app1">
  <input type="text" v-bind:value="msg" v-on:input="fn($event)">{{msg}}
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
<script>
  <!-- 案例 -->
  let vm = new Vue({
            el: "#app",
            data: {
              msg: "123"
            }
          })

  let vm1 = new Vue({
    el: "#app1",
    data: {
      msg: "123"
    },
    methods: {
      fn: function (e){
        this.msg = e.target.value;
      }
    }
  })


</script>
</body>
</html>